package com.gitee.order.controller;


import com.gitee.order.service.OrderService;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private OrderService orderService;

    @RequestMapping("create")
    public String createOrder(HttpServletRequest request) {

        String header = request.getHeader("X-Request-color");
        System.out.println(header);
        String result = restTemplate.getForObject("http://stock-mall/stock/reduct", String.class);

        return "order" + result;
    }

    @RequestMapping("findByOrderId/{id}")
    public String createOrder(@PathVariable("id") Integer id) {
        orderService.getOrder(id);
        return "order" + id;
    }



}
